package com.ly.common.running.dao;

import com.ly.common.running.model.BasePro;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;


@Repository
public class MybatisDaoImpl implements MybatisDao {
	private SqlSessionTemplate sqlSessionTemplate;

	public MybatisDaoImpl(SqlSessionTemplate sqlSessionTemplate) {
		this.sqlSessionTemplate = sqlSessionTemplate;
	}

	@Override
	public <T extends BasePro> List<T> selectList(T var) {
		return this.sqlSessionTemplate.selectList(var.getClass().getName().concat(".selectList"),var);
	}

	@Override
	public <T extends BasePro> T selectOne(T var) {
		return this.sqlSessionTemplate.selectOne(var.getClass().getName().concat(".selectOne"),var);
	}

	@Override
	public <T extends BasePro> T selectOne(String className, T var) {
		return this.sqlSessionTemplate.selectOne(className,var);
	}

	@Override
	public <T extends BasePro> void deleteByPrimaryKey(T var) {
		this.sqlSessionTemplate.delete(var.getClass().getName().concat(".deleteByPrimaryKey"),var);
	}

	@Override
	public <T extends BasePro> void insert(T var) {
		this.sqlSessionTemplate.insert(var.getClass().getName().concat(".insert"),var);
	}

	@Override
	public <T extends BasePro> List<T> selectList(String className, T var) {
		return this.sqlSessionTemplate.selectList(className,var);
	}

	@Override
	public <T extends BasePro> int update(T var) {
		return this.sqlSessionTemplate.update(var.getClass().getName().concat(".update"),var);
	}

	@Override
	public <T extends BasePro> T selectOne(String className, Map var) {
		return this.sqlSessionTemplate.selectOne(className,var);
	}

	@Override
	public <T extends BasePro> List<T> selectList(String className, Map var) {
		return this.sqlSessionTemplate.selectList(className,var);
	}

	@Override
	public <T extends BasePro> int update(String className, Map var) {
		return this.sqlSessionTemplate.update(className,var);
	}

	@Override
	public <T extends BasePro> void insert(String className, Map var) {
		this.sqlSessionTemplate.insert(className,var);
	}

	@Override
	public <T extends BasePro> void deleteByPrimaryKey(String className, Map var) {
		this.sqlSessionTemplate.delete(className,var);
	}

}
